package com.chuangke.sinotrukbudget.controller;

import java.util.Arrays;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.chuangke.core.http.HttpResult;
import com.chuangke.sinotrukbudget.service.BudgetAuditProgressMonitorService;

/**
 * bpc预算上报对象Controller
 * 
 * @author chuangke
 * @date "2022-10-21"
 */
@RestController
@RequestMapping("/budget/plan")
public class BudgetBpcPlanMonitorController {
	
	@Autowired
	private BudgetAuditProgressMonitorService budgetAuditProgressMonitorService;

	@PreAuthorize("hasAuthority('login:action')")
	@GetMapping("/monitor/summary")
	public HttpResult monitorSummary() {
		return HttpResult.ok(budgetAuditProgressMonitorService.progressSummary());
	}

	@PreAuthorize("hasAuthority('login:action')")
	@GetMapping("/monitor/orderdetail/{nodes}")
	public HttpResult monitorOrderDetail(@PathVariable String[] nodes) {
		return HttpResult.ok(budgetAuditProgressMonitorService.progressDetailByOrderDept(Arrays.asList(nodes)));
	}

	@PreAuthorize("hasAuthority('login:action')")
	@GetMapping("/monitor/userdetail/{nodes}")
	public HttpResult monitorUserDetail(@PathVariable String[] nodes) {
		return HttpResult.ok(budgetAuditProgressMonitorService.progressDetailByAuditUser(Arrays.asList(nodes)));
	}

}
